/*
 * ViewLeaseForm.java
 *
 * Created on __DATE__, __TIME__
 */

package edu.washburn.cm333.project.gui;

import java.util.List;

import javax.persistence.EntityManager;

import edu.washburn.cm333.project.entities.Lease;
import edu.washburn.cm333.project.entities.PropertyManager;

/**
 *
 * @author  __USER__
 */
public class ViewLeaseForm extends javax.swing.JFrame {

	/** Creates new form ViewLeaseForm */
	public ViewLeaseForm() {
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		btnExit = new javax.swing.JButton();
		EntityManager em = PropertyManager.getEntityManager();
		List<Lease> leaseList = em.createQuery("select t from Lease t",
				Lease.class).getResultList();
		jComboBox1 = new Java2sAutoComboBox(leaseList);
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		rentDsp = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jLabel5 = new javax.swing.JLabel();
		jLabel6 = new javax.swing.JLabel();
		jLabel7 = new javax.swing.JLabel();
		jLabel8 = new javax.swing.JLabel();
		jLabel9 = new javax.swing.JLabel();
		unitDsp = new javax.swing.JLabel();
		addressDsp = new javax.swing.JLabel();
		cityDsp = new javax.swing.JLabel();
		stateDsp = new javax.swing.JLabel();
		zipDsp = new javax.swing.JLabel();
		jLabel15 = new javax.swing.JLabel();
		jLabel16 = new javax.swing.JLabel();
		jLabel17 = new javax.swing.JLabel();
		fnameDsp = new javax.swing.JLabel();
		lnameDsp = new javax.swing.JLabel();
		ssnDsp = new javax.swing.JLabel();
		lengthDsp = new javax.swing.JLabel();

		btnExit.setText("Exit");
		btnExit.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnExitActionPerformed(evt);
			}
		});

		jComboBox1.setSelectedIndex(-1);
		jComboBox1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jComboBox1ActionPerformed(evt);
			}
		});

		jLabel1.setText("Select Unit");

		jLabel2.setText("Rent");

		jLabel4.setText("Length");

		jLabel5.setText("Unit");

		jLabel6.setText("Address");

		jLabel7.setText("City");

		jLabel8.setText("State");

		jLabel9.setText("Zip");

		jLabel15.setText("First Name");

		jLabel16.setText("Last Name");

		jLabel17.setText("SSN");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGap(242, 242, 242)
								.addComponent(btnExit,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										103,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addContainerGap(324, Short.MAX_VALUE))
				.addGroup(
						layout.createSequentialGroup()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING,
												false)
												.addGroup(
														javax.swing.GroupLayout.Alignment.LEADING,
														layout.createSequentialGroup()
																.addGap(30, 30,
																		30)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														jLabel4)
																												.addComponent(
																														jLabel2))
																								.addGap(36,
																										36,
																										36)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														lengthDsp)
																												.addComponent(
																														rentDsp))
																								.addGap(76,
																										76,
																										76)
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING)
																												.addComponent(
																														jLabel5,
																														javax.swing.GroupLayout.Alignment.TRAILING)
																												.addComponent(
																														jLabel6,
																														javax.swing.GroupLayout.Alignment.TRAILING)))
																				.addComponent(
																						jLabel7)
																				.addComponent(
																						jLabel8)
																				.addComponent(
																						jLabel9))
																.addPreferredGap(
																		javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																		173,
																		Short.MAX_VALUE)
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.TRAILING)
																				.addComponent(
																						cityDsp)
																				.addComponent(
																						stateDsp)
																				.addComponent(
																						zipDsp)
																				.addComponent(
																						addressDsp)
																				.addComponent(
																						unitDsp)))
												.addGroup(
														javax.swing.GroupLayout.Alignment.LEADING,
														layout.createSequentialGroup()
																.addGap(34, 34,
																		34)
																.addComponent(
																		jLabel1)
																.addGap(39, 39,
																		39)
																.addComponent(
																		jComboBox1,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		265,
																		javax.swing.GroupLayout.PREFERRED_SIZE)))
								.addGap(65, 65, 65)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addComponent(jLabel15)
												.addGroup(
														layout.createSequentialGroup()
																.addGap(35, 35,
																		35)
																.addComponent(
																		jLabel17))
												.addComponent(jLabel16))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED,
										141, Short.MAX_VALUE)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.TRAILING)
												.addComponent(ssnDsp)
												.addComponent(fnameDsp)
												.addComponent(lnameDsp))
								.addContainerGap()));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						javax.swing.GroupLayout.Alignment.TRAILING,
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel1)
												.addComponent(
														jComboBox1,
														javax.swing.GroupLayout.PREFERRED_SIZE,
														javax.swing.GroupLayout.DEFAULT_SIZE,
														javax.swing.GroupLayout.PREFERRED_SIZE))
								.addGap(54, 54, 54)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel2)
												.addComponent(rentDsp)
												.addComponent(jLabel5)
												.addComponent(jLabel15)
												.addComponent(unitDsp)
												.addComponent(fnameDsp))
								.addGap(38, 38, 38)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel4)
												.addComponent(jLabel6)
												.addComponent(lengthDsp)
												.addComponent(jLabel16)
												.addComponent(addressDsp)
												.addComponent(lnameDsp))
								.addGap(36, 36, 36)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel7)
												.addComponent(cityDsp)
												.addComponent(jLabel17)
												.addComponent(ssnDsp))
								.addGap(34, 34, 34)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel8)
												.addComponent(stateDsp))
								.addGap(38, 38, 38)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.BASELINE)
												.addComponent(jLabel9)
												.addComponent(zipDsp))
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED,
										56, Short.MAX_VALUE)
								.addComponent(btnExit).addContainerGap()));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
		Object o = ((Java2sAutoComboBox) jComboBox1).autoTextFieldEditor
				.getItem();
		if (o instanceof Lease) {
			Lease a = (Lease) o;
			lengthDsp.setText(String.valueOf(a.getTermMonths()));
			rentDsp.setText(a.getRent());

			unitDsp.setText(a.getProperty().getUnit());
			addressDsp.setText(a.getProperty().getStreetAddress());
			cityDsp.setText(a.getProperty().getCity());
			stateDsp.setText(a.getProperty().getState());
			zipDsp.setText(a.getProperty().getZip());

			fnameDsp.setText(a.getTenants().getFName());
			lnameDsp.setText(a.getTenants().getLName());
			ssnDsp.setText(a.getTenants().getTaxId());
		}
	}

	private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
		this.setVisible(false);
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new ViewLeaseForm().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JLabel addressDsp;
	private javax.swing.JButton btnExit;
	private javax.swing.JLabel cityDsp;
	private javax.swing.JLabel fnameDsp;
	private javax.swing.JComboBox jComboBox1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel15;
	private javax.swing.JLabel jLabel16;
	private javax.swing.JLabel jLabel17;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JLabel lengthDsp;
	private javax.swing.JLabel lnameDsp;
	private javax.swing.JLabel rentDsp;
	private javax.swing.JLabel ssnDsp;
	private javax.swing.JLabel stateDsp;
	private javax.swing.JLabel unitDsp;
	private javax.swing.JLabel zipDsp;
	// End of variables declaration//GEN-END:variables

}